package ReverseStream.OutputStreamWriter;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 * @Author: ylc
 * @Description:转换流
 * @Date Created in 2022-04-27 14:17
 */
public class OutputStreamWriterDemo {
    /*
        java.io.OutputStreamWriter extends Writer
            OutputStreamWriter: 是字符流通向字节流的桥梁：可使用指定的 charset 将要写入流中的字符编码成字节。(编码:把能看懂的变成看不懂)

        构造方法:
            OutputStreamWriter(OutputStream out)创建使用默认字符编码的 OutputStreamWriter。
            OutputStreamWriter(OutputStream out, String charsetName) 创建使用指定字符集的 OutputStreamWriter。
    */
    public static void main(String[] args) throws IOException {
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("Study05\\GBK格式的文本.txt"),"GBK");
        int len = 0;
        osw.write("叶良承");
        osw.flush();
        osw.close();

    }
}
